<!--suppress ALL -->
<template>
  <div class="main">
    <p class="title">{{ dayNow }}</p>
    <ul class="navList">
      <li class="item" @click="toPage(index)" v-for="(item,index) in links" :key="index"
          :class="{active:index===activeIndex}">
        {{ item }}
      </li>
    </ul>
    <p class="add" @click="toPage(3)">
      <span class="icon">+</span>
      新建
    </p>
  </div>
</template>

<script>
import {defineComponent, ref, computed, reactive} from "vue";

export default defineComponent({
  methods: {},
  setup(props, context) {
    const dayNow = computed(() => {
      const date = new Date()
      const year = date.getFullYear()
      const mouth = date.getMonth() + 1
      const day = date.getDate()
      return `${year}-${mouth}-${day}`
    })

    const links = reactive(['待办事项', '已完成'])
    const activeIndex = ref(0)
    const toPage = (index) => {
      console.log(index)
      activeIndex.value = index
      context.emit('toPage', activeIndex.value)
    }
    return {dayNow, links, activeIndex, toPage}
  }
})
</script>

<style lang="scss" scoped>
@import "styles/main.scss";

.main {
  background: $nav-bg-color;
  position: relative;
  user-select: none;

  .title {
    height: 40px;
    line-height: 40px;
    font-size: 30px;
    color: $basic-color;
    font-weight: bold;
    margin-bottom: 40px;
    cursor: default;
  }

  .navList {
    list-style: none;
    li {
      height: 40px;
      width: 140px;
      margin: 20px auto;
      font-size: 18px;
      line-height: 40px;
      cursor: pointer;
    }

    .active {
      background: $basic-color;
      color: white;
      border-radius: 20px;
    }
  }

  .add {
    position: absolute;
    bottom: 40px;
    width: 100%;
    height: 40px;
    line-height: 40px;
    cursor: pointer;

    span {
      display: inline-block;
      margin-right: 10px;
      border-radius: 20px;
      height: 40px;
      width: 40px;
      color: white;
      background: $basic-color;
      font-size: larger;
    }
  }
}
</style>